package com.rowenci.iot_agriculture.mapper;

import com.rowenci.iot_agriculture.bean.iot.Message;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;


public interface MessageDao extends JpaRepository<Message, Integer> {

    Message findByComId(Integer comId);

    @Transactional
    @Modifying
    @Query(value = "update Message message set message.info = ?1 where message.comId = ?2")
    void updateMessage(String info, Integer comId);

}
